package com.voltmao.webpro.utils.file;



import com.aspose.words.Document;
import com.aspose.words.SaveFormat;

import java.io.File;
import java.io.FileOutputStream;

/**
 * 文件说明
 *
 * @author zhanglin
 * @date 2018/4/25
 */
public class Word2PDF {
    public static void doc2pdf(String inPath, String outPath) {
        try {
            long old = System.currentTimeMillis();
            // 新建一个空白pdf文档
            File inFile = new File(inPath);
            File file = new File(outPath);
            FileOutputStream os = new FileOutputStream(file);
            // Address是将要被转化的word文档
            Document doc = new Document(inFile.getAbsolutePath());
            // 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
            doc.save(os, SaveFormat.PDF);
            // EPUB, XPS, SWF 相互转换
            long now = System.currentTimeMillis();
            // 转化用时
            System.out.println("共耗时：" + ((now - old) / 1000.0) + "秒");
            os.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

//    public static void main(String[] args) {
//        Word2PDF.doc2pdf("/D:/1.doc","D:/1.pdf");
//    }

}
